<template>
	<!-- 消防测试记录表 -->
	<view class="">
		<view class="files">
			<view class="tabs">
				<fui-list bottomBorder title="基本信息">
					<view class="tab">

						<fui-list-cell>
							<text>登记人</text>
							<text class="fui-text__explain">{{inspectionStaff.name}}</text>
						</fui-list-cell>

						<fui-list-cell>
							<text>日期</text>
							<text class="fui-text__explain">{{inspectionStaff.data}}</text>
						</fui-list-cell>

					</view>
				</fui-list>
				<!-- a -->
				<fui-divider text="消防火灾自动报警系统"></fui-divider>
				<fui-list bottomBorder title="消防报警主机及电源测试情况">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="i.i2" label="工程名称" textAlign="right"></fui-input>
						<!-- <fui-input placeholder="请输入" required v-model="a.a1" label="测试区域" textAlign="right"></fui-input> -->
						<fui-input placeholder="请选择" required readonly @click="onShowOps(1)" v-model="a.a2" label="报警功能"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" required readonly @click="onShowOps(2)" v-model="a.a3" label="显示功能"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" required readonly @click="onShowOps(3)" v-model="a.a4"
							label="主/备电切换功能" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="a.a5" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<!-- b -->
				<fui-list bottomBorder title="消防报警主机与外设备报警通讯测试情况">
					<view class="tab">
						<!-- <fui-input placeholder="请输入" required v-model="b.b1" label="测试区域" textAlign="right"></fui-input> -->
						<fui-input placeholder="请选择" @click="onShowOps(4)" readonly required v-model="b.b2" label="报警功能"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(5)" readonly required v-model="b.b3" label="显示功能"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(6)" readonly required v-model="b.b4" label="编码位置"
							textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="b.b5" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-divider text="消防联动控制系统"></fui-divider>
				<fui-divider text="自动/手动远程控制水泵功能测试情况"></fui-divider>
				<fui-list bottomBorder title="喷淋泵">
					<view class="tab">
						<fui-input readonly label="1#泵" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(7)" v-model="c.c1" readonly required label="运行情况"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(8)" v-model="c.c2" readonly required
							label="指示显示情况" textAlign="right"></fui-input>
						<fui-input readonly label="2#泵" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(9)" v-model="c.c3" readonly required label="运行情况"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(10)" v-model="c.c4" readonly required
							label="指示显示情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="c.c9" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-list bottomBorder title="消火栓泵">
					<view class="tab">
						<fui-input readonly required label="1#泵" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(11)" v-model="c.c5" readonly required
							label="运行情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(12)" v-model="c.c6" readonly required
							label="指示显示情况" textAlign="right"></fui-input>
						<fui-input readonly label="2#泵" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(13)" v-model="c.c7" readonly required
							label="运行情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(14)" v-model="c.c8" readonly required
							label="指示显示情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="c.c9" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<!-- d -->
				<fui-divider text="防排烟风机控制功能测试情况"></fui-divider>
				<fui-list bottomBorder title="正压风机">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="d.d1" label="编号" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(15)" required v-model="d.d2"
							label="启停情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(16)" required v-model="d.d3"
							label="控制中心显示情况" textAlign="right"></fui-input>
						<!-- 	<fui-input readonly required  label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="d.d4" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea> -->
					</view>
				</fui-list>

				<fui-list bottomBorder title="排烟风机">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="d.d5" label="编号" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(17)" required v-model="d.d6"
							label="启停情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(18)" required v-model="d.d7"
							label="控制中心显示情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="d.d8" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-list bottomBorder title="其他联动设备测试情况">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(19)" required v-model="e.e1"
							label="启停情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(20)" required v-model="e.e2"
							label="控制中心显示情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="e.e3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-divider text="自动喷淋灭火系统"></fui-divider>

				<fui-list bottomBorder title="末端试水情况">
					<view class="tab">
						<!-- <fui-input placeholder="请输入" required v-model="f.f1" label="测试区域" textAlign="right"></fui-input> -->
						<fui-input placeholder="请选择" readonly @click="onShowOps(21)" required v-model="f.f2"
							label="报警/联动功能" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="f.f3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-list bottomBorder title="水流指示器报警情况">
					<view class="tab">
						<!-- <fui-input placeholder="请输入" required v-model="j.j1" label="测试区域" textAlign="right"></fui-input> -->
						<fui-input placeholder="请选择" readonly @click="onShowOps(22)" required v-model="j.j2"
							label="报警/联动功能" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="j.j3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-list bottomBorder title="湿式报警阀">
					<view class="tab">
						<fui-input placeholder="请选择" required readonly @click="onShowOps(48)" v-model="k.k1"
							label="报警动作情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(23)" required v-model="k.k2"
							label="联动工作情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="k.k3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-list bottomBorder title="其他阀件功能检查情况">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(47)" required v-model="l.l1"
							label="开关情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(24)" required v-model="l.l2"
							label="信号反馈" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="l.l3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-list bottomBorder title="喷淋稳压泵测试情况">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(25)" required v-model="h.h1"
							label="电源供电情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(26)" required v-model="h.h2"
							label="水泵运行情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(27)" required v-model="h.h3"
							label="联动工作情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(28)" required v-model="h.h4"
							label="其他阀件情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="h.h5" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>


				<fui-list bottomBorder title="水泵接合器检查情况">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="s.s1" label="检查位置" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(29)" required v-model="s.s2"
							label="阀件情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(30)" required v-model="s.s3"
							label="井壁情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="s.s4" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-divider text="消火栓灭火系统"></fui-divider>
				<fui-list bottomBorder title="室内消火栓检查情况">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="q.q1" label="检查位置" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(31)" required v-model="q.q2"
							label="室内消火栓组件情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(32)" required v-model="q.q3"
							label="联动启动情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(33)" required v-model="q.q4"
							label="静压工作压力" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(34)" required v-model="q.q5"
							label="动压工作压力" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="q.q6" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-list bottomBorder title="消火栓稳压泵情况">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(35)" required v-model="w.w1"
							label="电源供电情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(36)" required v-model="w.w2"
							label="水泵运行情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(37)" required v-model="w.w3"
							label="联动工作情况" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(38)" required v-model="w.w4"
							label="其他阀件情况" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="w.w5" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-divider text="消防水池位情况"></fui-divider>

				<fui-list bottomBorder title="消防水池位情况">
					<view class="tab">
						<fui-input placeholder="请输入" required v-model="r.r1" label="检查孔位置"
							textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(39)" required v-model="r.r2"
							label="水池水位" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="r.r3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>

				<fui-divider text="气体灭火系统"></fui-divider>
				<fui-list bottomBorder title="气体灭火控制部分">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(40)" required v-model="t.t1"
							label="报警功能" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(41)" required v-model="t.t2"
							label="手/自动控制功能" textAlign="right"></fui-input>
						<!-- <fui-input readonly required  label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="t.t3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea> -->
					</view>
				</fui-list>

				<fui-list bottomBorder title="储压设备">
					<view class="tab">
						<fui-input placeholder="请选择" readonly @click="onShowOps(42)" required v-model="y.y1"
							label="外观质量" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(43)" required v-model="y.y2"
							label="气体气压" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" readonly @click="onShowOps(44)" required v-model="y.y3"
							label="控制机构（含电磁阀）" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="y.y4" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<fui-divider text="应急照明、疏散指示系统"></fui-divider>
				<fui-list bottomBorder title="应急照明、疏散指示系统">
					<view class="tab">
						<fui-input placeholder="请选择" @click="onShowOps(45)" required readonly v-model="u.u1"
							label="外观质量" textAlign="right"></fui-input>
						<fui-input placeholder="请选择" @click="onShowOps(46)" required readonly v-model="u.u2"
							label="联动切换功能" textAlign="right"></fui-input>
						<fui-input readonly required label="问题及处理情况" textAlign="right"></fui-input>
						<u--textarea v-model="u.u3" placeholder="请输入问题及处理情况" count maxlength="250"></u--textarea>
					</view>
				</fui-list>
				<br />
				<fui-input readonly label="其他情况备注" textAlign="right"></fui-input>
				<u--textarea v-model="i.i1" placeholder="请输入" count maxlength="250"></u--textarea>
			</view>



			<view class="tab_ops">
				<!-- 	<view style="width: 100%; display: flex; justify-content: space-between;">
					<fui-button btnSize="small" >巡查人员签字</fui-button>
					<fui-button btnSize="small"  >安全主管签字</fui-button>
				</view> -->
				<view style="padding-top: 40rpx;">
					<fui-button @click="submit" type="success">提交</fui-button>
				</view>
			</view>
			<view>
				<u-picker @confirm="onOpsOne" @cancel="showOpsOne = !showOpsOne" :show="showOpsOne"
					:columns="columnsOne"></u-picker>
			</view>
			<view>
				<u-datetime-picker :minDate="minDate" :maxDate="maxDate" :formatter="formatter" @confirm="onTime"
					@cancel="showTime =!showTime" :show="showTime" mode="datetime"></u-datetime-picker>
			</view>
		</view>
	</view>
</template>

<script>
	import moment, {
		duration
	} from "moment"
	import {
		BASE_IP
	} from '@/common/http/url.js'
	// import test from "../../../uni_modules/uview-plus/libs/function/test"
	// import text from "../../../uni_modules/uview-plus/libs/config/props/text"
	import tools from "@/tools/tools.js"
	export default {
		name: "buildingFireProtection",
		data() {
			return {
				user: "",
				inspectionStaff: {
					name: "",
					data: "",
					time: ""
				},
				v1: "",
				v2: "",
				columnsOne: [
					['正常', '异常']
				],
				showOpsOne: false,
				showTime: false,
				regime: "",
				year: "",
				month: "",
				day: "",
				ops: {
					c1: "", //消防设施名称
					c2: "", //部门
					c3: "", //位置
					c4: "", //数量
					c5: "", //状态
					c6: "", //责任人
					c7: "", //备注
				},
				opsone: {
					c1: "", //消防设施名称
					c2: "", //部门
					c3: "", //设置位置
					c4: "", //数量
					c5: "", //器材维护保养状况
					c6: "", //责任人
					c7: "", //备注
				},
				opstow: {
					c1: "", //消防设施名称
					c2: "", //部门
					c3: "", //设置位置
					c4: "", //数量
					c5: "", //状态
					c6: "", //送检日期
				},
				time: "",
				index: 0,
				minDate: null,
				maxDate: null,
				tid: 0,
				a: {
					a1: "",
					a2: "正常",
					a3: "正常",
					a4: "正常",
					a5: "无隐患报告",
				},
				b: {
					b1: "",
					b2: "正常",
					b3: "正常",
					b4: "正常",
					b5: "无隐患报告",
				},
				c: {
					c1: "正常",
					c2: "正常",
					c3: "正常",
					c4: "正常",
					c5: "正常",
					c6: "正常",
					c7: "正常",
					c8: "正常",
					c9: "无隐患报告",
				},
				d: {
					d1: "",
					d2: "正常",
					d3: "正常",
					d4: "无隐患报告",
					d5: "",
					d6: "正常",
					d7: "正常",
					d8: "无隐患报告",
				},
				e: {
					e1: "正常",
					e2: "正常",
					e3: "无隐患报告"
				},
				f: {
					f1: "",
					f2: "正常",
					f3: "无隐患报告"
				},
				j: {
					j1: "",
					j2: "正常",
					j3: "无隐患报告"
				},
				k: {
					k1: "正常",
					k2: "正常",
					k3: "无隐患报告"
				},
				l: {
					l1: "正常",
					l2: "正常",
					l3: "无隐患报告"
				},
				h: {
					h1: "正常",
					h2: "正常",
					h3: "正常",
					h4: "正常",
					h5: "无隐患报告",
				},
				s: {
					s1: "",
					s2: "正常",
					s3: "正常",
					s4: "无隐患报告",
				},
				q: {
					q1: "",
					q2: "正常",
					q3: "正常",
					q4: "正常",
					q5: "正常",
					q6: "无隐患报告",
				},
				w: {
					w1: "正常",
					w2: "正常",
					w3: "正常",
					w4: "正常",
					w5: "无隐患报告",
				},
				r: {
					r1: "",
					r2: "正常",
					r3: "无隐患报告",
				},
				t: {
					t1: "正常",
					t2: "正常",
					t3: "无隐患报告",
				},
				y: {
					y1: "正常",
					y2: "正常",
					y3: "正常",
					y4: "无隐患报告",
				},
				u: {
					u1: "正常",
					u2: "正常",
					u3: "无隐患报告",
				},
				i: {
					i1: "无",
					i2: ""
				},
				modeName: [
					['喷淋泵', '消火栓泵']
				],
				isSubmit: false,
				preset: ""
			}
		},
		mounted() {
			this.calculateMinMaxDates();
		},
		methods: {
			/**
			 * 
			 * @param {Object} path 转入要签字的路径
			 */
			onSignatures(path) {
				let user = uni.getStorageSync("user")
				if (user.signature == "" || user.signature == undefined || user.signature == null) {
					uni.showModal({
						title: "提示",
						content: "用户未上传签名请前往“预设功能-添加操作员-输入账号-添加签名”，如果已添加操作员上传签名即可",
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								return
							}
						}
					})
					return
				}
				let docPath = path
				let url = BASE_IP + user.signature
				tools.instImgPdf(path, user.signature, 420, 430)
				// console.log(url)
				// let _this = this
				// uni.downloadFile({ //下载
				// 	url: url, //图片下载地址
				// 	success: res => {
				// 		if (res.statusCode === 200) {
				// 			uni.saveFile({
				// 				tempFilePath: res.tempFilePath,
				// 				success: (r) => {
				// 					console.log(r)
				// 					_this.upSignatures(r.savedFilePath, docPath)
				// 				}
				// 			})
				// 		}
				// 	}
				// });
			},
			/** 签字函数
			 * @param {Object} filePath 签字图片
			 * @param {Object} docPath  要签字的文档
			 */
			upSignatures(filePath, docPath) {
				console.log(filePath, docPath)
				let user = uni.getStorageSync("user")
				let url = BASE_IP + "pc/regulatory/signature/word"
				uni.uploadFile({
					header: {
						"Authorization": user.token,
					},
					name: "file",
					url: url,
					formData: {
						"unitId": user.unitId,
						"path": docPath
					},
					filePath: filePath,
					success: (res) => {
						if (res.statusCode == 500) {
							uni.showToast({
								title: "上传失败",
								icon: "error"
							})
							return
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "上传失败,请重试",
							icon: "error"
						})
					}
				})
			},
			/**
			 * 盖章
			 * @param {Object} path 转入要盖章的文件路径
			 */
			onSeal(path) {
				let pralldata = uni.getStorageSync("pralldata")
				// console.log(pralldata)
				let docPath = path
				if (pralldata.unitFireSeal == "" || pralldata.unitFireSeal == undefined) {
					uni.showModal({
						title: "提示",
						content: "单位未上传消防专用章",
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								return
							}
						}
					})
					return
				}
				let url = BASE_IP + pralldata.unitFireSeal
				tools.instImgPdf(path, pralldata.unitFireSeal, 100, 430)
				// console.log(url)
				// uni.downloadFile({ //下载
				// 	url: url, //图片下载地址
				// 	success: res => {
				// 		if (res.statusCode === 200) {
				// 			uni.saveFile({
				// 				tempFilePath: res.tempFilePath,
				// 				success: (r) => {
				// 					// console.log(r)
				// 					this.upLoadSeal(r.savedFilePath, docPath)
				// 				}
				// 			})
				// 		}
				// 	}
				// });
			},
			/** 盖章函数
			 * @param {Object} filePath 印章图片
			 * @param {Object} docPath  要盖章的文档
			 */
			upLoadSeal(filePath, docPath) {
				let user = uni.getStorageSync("user")
				let url = BASE_IP + "pc/regulatory/update/word"
				uni.uploadFile({
					header: {
						"Authorization": user.token,
					},
					name: "file",
					url: url,
					formData: {
						"unitId": user.unitId,
						"path": docPath
					},
					filePath: filePath,
					success: (res) => {
						// console.log(res)
						if (res.statusCode == 500) {
							uni.showToast({
								title: "盖章失败",
								icon: "error"
							})
							return
						}
						if (res.statusCode == 404) {
							uni.showToast({
								title: "盖章失败",
								icon: "error"
							})
							return
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "盖章失败,请重试",
							icon: "error"
						})
					}
				})
			},
			onSelectTime(index) {
				this.tid = index
				this.showTime = !this.showTime
			},
			calculateMinMaxDates() {
				const today = moment().startOf("day");
				const minDate = today.clone().subtract(60, "days");
				const maxDate = today.clone().startOf("day");

				this.minDate = minDate.valueOf();
				this.maxDate = maxDate.valueOf();
			},
			formatter(type, value) {
				if (type === 'year') {
					return `${value}年`
				}
				if (type === 'month') {
					return `${value}月`
				}
				if (type === 'day') {
					return `${value}日`
				}
				if (type === 'hour') {
					return `${value}时`;
				}
				if (type === 'minute') {
					return `${value}分`;
				}
				return value
			},
			onTime(res) {
				const timestamp = res.value
				const formattedDateTime = moment(timestamp).format("YYYY-MM-DD HH:mm:ss");
				switch (this.tid) {
					case 1: {
						this.faultSituation.c1 = formattedDateTime
						break
					}
					case 2: {
						this.faultMaintenanceCondition.c3 = formattedDateTime
						break
					}
				}
				this.showTime = !this.showTime
				// console.log(formattedDateTime)
			},
			onShowOps(index) {
				this.index = index
				this.showOpsOne = !this.showOpsOne
			},
			onOpsOne(res) {
				// this.situation = res.value[0]
				// console.log(res)
				switch (this.index) {
					case 1: {
						this.a.a2 = res.value[0]
						break
					}
					case 2: {
						this.a.a3 = res.value[0]
						break
					}
					case 3: {
						this.a.a4 = res.value[0]
						break
					}
					case 4: {
						this.b.b2 = res.value[0]
						break
					}
					case 5: {
						this.b.b3 = res.value[0]
						break
					}
					case 6: {
						this.b.b4 = res.value[0]
						break
					}
					case 7: {
						this.c.c1 = res.value[0]
						break
					}
					case 8: {
						this.c.c2 = res.value[0]
						break
					}
					case 9: {
						this.c.c3 = res.value[0]

						break
					}
					case 10: {
						this.c.c4 = res.value[0]

						break
					}
					case 11: {
						this.c.c5 = res.value[0]

						break
					}
					case 12: {
						this.c.c6 = res.value[0]

						break
					}
					case 13: {
						this.c.c7 = res.value[0]

						break
					}
					case 14: {
						this.c.c8 = res.value[0]

						break
					}
					case 15: {
						this.d.d2 = res.value[0]

						break
					}
					case 16: {
						this.d.d3 = res.value[0]

						break
					}
					case 17: {
						this.d.d6 = res.value[0]

						break
					}
					case 18: {
						this.d.d7 = res.value[0]

						break
					}

					case 19: {
						this.e.e1 = res.value[0]

						break
					}

					case 20: {
						this.e.e2 = res.value[0]

						break
					}
					case 21: {
						this.f.f2 = res.value[0]

						break
					}
					case 22: {
						this.j.j2 = res.value[0]

						break
					}
					case 23: {
						this.k.k2 = res.value[0]

						break
					}
					case 24: {
						this.l.l2 = res.value[0]

						break
					}
					case 25: {
						this.h.h1 = res.value[0]

						break
					}
					case 26: {
						this.h.h2 = res.value[0]

						break
					}
					case 27: {
						this.h.h3 = res.value[0]

						break
					}
					case 28: {
						this.h.h4 = res.value[0]

						break
					}
					case 29: {
						this.s.s2 = res.value[0]

						break
					}
					case 30: {
						this.s.s3 = res.value[0]

						break
					}
					case 31: {
						this.q.q2 = res.value[0]

						break
					}
					case 32: {
						this.q.q3 = res.value[0]

						break
					}
					case 33: {
						this.q.q4 = res.value[0]

						break
					}
					case 34: {
						this.q.q5 = res.value[0]

						break
					}
					case 35: {
						this.w.w1 = res.value[0]

						break
					}
					case 36: {
						this.w.w2 = res.value[0]

						break
					}
					case 37: {
						this.w.w3 = res.value[0]

						break
					}
					case 38: {
						this.w.w4 = res.value[0]

						break
					}
					case 39: {
						this.r.r2 = res.value[0]

						break
					}
					case 40: {
						this.t.t1 = res.value[0]

						break
					}
					case 41: {
						this.t.t2 = res.value[0]

						break
					}
					case 42: {
						this.y.y1 = res.value[0]

						break
					}
					case 43: {
						this.y.y2 = res.value[0]

						break
					}
					case 44: {
						this.y.y3 = res.value[0]

						break
					}
					case 45: {
						this.u.u1 = res.value[0]

						break
					}
					case 46: {
						this.u.u2 = res.value[0]

						break
					}
					case 47: {
						this.l.l1 = res.value[0]

						break
					}
					case 48: {
						this.k.k1 = res.value[0]

						break
					}
				}
				// this.faultSituation.c9 = res.value[0]
				this.showOpsOne = !this.showOpsOne
			},
			submit() {

				if (this.isSubmit) {
					uni.showToast({
						title: "请勿重复提交",
						icon: "error"
					})
					return
				}




				// if (this.a.a1 == "") {
				// 	uni.showToast({
				// 		title: "表单填写不完整",
				// 		icon: "error"
				// 	})
				// 	return
				// }
				// if (this.b.b1 == "") {
				// 	uni.showToast({
				// 		title: "表单填写不完整",
				// 		icon: "error"
				// 	})
				// 	return
				// }
				if (this.d.d1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.d.d5 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				// if (this.f.f1 == "") {
				// 	uni.showToast({
				// 		title: "表单填写不完整",
				// 		icon: "error"
				// 	})
				// 	return
				// }

				// if (this.j.j1 == "") {
				// 	uni.showToast({
				// 		title: "表单填写不完整",
				// 		icon: "error"
				// 	})
				// 	return
				// }

				if (this.k.k1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.l.l1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.s.s1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.q.q1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.r.r1 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}

				if (this.i.i2 == "") {
					uni.showToast({
						title: "表单填写不完整",
						icon: "error"
					})
					return
				}


				let url = BASE_IP + "pc/record/record/fire/fireTestRecordSheet"

				let classifyId = this.regime.classifyId
				// console.log(this.regime)
				let user = uni.getStorageSync("user")

				let json1 = {
					name: this.inspectionStaff.name,
					data: this.inspectionStaff.data,
					a1: this.a.a1,
					a2: this.a.a2,
					a3: this.a.a3,
					a4: this.a.a4,
					a5: this.a.a5,
					b1: this.b.b1,
					b2: this.b.b2,
					b3: this.b.b3,
					b4: this.b.b4,
					b5: this.b.b5,
					c1: this.c.c1,
					c2: this.c.c2,
					c3: this.c.c3,
					c4: this.c.c4,
					c5: this.c.c5,
					c6: this.c.c6,
					c7: this.c.c7,
					c8: this.c.c8,
					c9: this.c.c9,
					d1: this.d.d1,
					d2: this.d.d2,
					d3: this.d.d3,
					d4: this.d.d4,
					d5: this.d.d5,
					d6: this.d.d6,
					d7: this.d.d7,
					d8: this.d.d8,
					e1: this.e.e1,
					e2: this.e.e2,
					e3: this.e.e3,
					f1: this.f.f1,
					f2: this.f.f2,
					f3: this.f.f3,
					j1: this.j.j1,
					j2: this.j.j2,
					j3: this.j.j3,
					k1: this.k.k1,
					k2: this.k.k2,
					k3: this.k.k3,
					l1: this.l.l1,
					l2: this.l.l2,
					l3: this.l.l3,
					h1: this.h.h1,
					h2: this.h.h2,
					h3: this.h.h3,
					h4: this.h.h4,
					h5: this.h.h5,
					s1: this.s.s1,
					s2: this.s.s2,
					s3: this.s.s3,
					s4: this.s.s4,
					q1: this.q.q1,
					q2: this.q.q2,
					q3: this.q.q3,
					q4: this.q.q4,
					q5: this.q.q5,
					q6: this.q.q6,
					w1: this.w.w1,
					w2: this.w.w2,
					w3: this.w.w3,
					w4: this.w.w4,
					w5: this.w.w5,
					r1: this.r.r1,
					r2: this.r.r2,
					r3: this.r.r3,
					t1: this.t.t1,
					t2: this.t.t2,
					t3: this.t.t3,
					y1: this.y.y1,
					y2: this.y.y2,
					y3: this.y.y3,
					y4: this.y.y4,
					u1: this.u.u1,
					u2: this.u.u2,
					u3: this.u.u3,
					i1: this.i.i1,
					i2: this.i.i2,
				}
				let flag_storage = true
				// let user = uni.getStorageSync("user")
				if (user.signature == "" || user.signature == undefined || user.signature == null) {
					uni.showModal({
						title: "提示",
						content: "用户未上传签名请前往“预设功能-添加操作员-输入账号-添加签名”，如果已添加操作员上传签名即可",
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								flag_storage = false
								uni.navigateTo({
									url: "/pages/preinstall/preinstall"
								})
								return
							}
						}
					})
					return
				}

				if (!flag_storage) {
					return
				}

				let pralldata = this.preset
				console.log(pralldata)
				let falg_seal = true
				if (pralldata.unitFireSeal == "" || pralldata.unitFireSeal == undefined) {
					uni.showModal({
						title: "提示",
						content: "单位未上传消防专用章,请前往“预设功能-单位消防专用章”上传",
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								falg_seal = false
								uni.navigateTo({
									url: "/pages/preinstall/preinstall"
								})
								return
							}
						}
					})
					return
				}

				if (!falg_seal) {
					return
				}
				uni.showLoading({
					title: "正在提交"
				})
				this.isSubmit = !this.isSubmit
				uni.request({
					url: url,
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						unitId: user.unitId,
						name: user.nickName,
						classifyId: classifyId,
						json: JSON.stringify(json1),
						uuid : user.uuid
					},
					method: "POST",
					success: (res) => {
						console.log(res)

						if (res.statusCode == 200) {
							uni.showToast({
								title: "上传成功",
								icon: "success"
							})
							// this.onSeal(res.data.path)
							// this.onSignatures(res.data.path)
							setTimeout((r) => {
								uni.navigateBack({
									delta: 1,
									success: function() {
										const pages = getCurrentPages(); //获取当前页面栈
										const prevPage = pages[pages.length -
											1]; //获取上一个页面实例对象
										prevPage.getCollapseDatas(); //调用上一个页面的onLoad方法
									}
								});
							}, 1500)

							return
						}

						if (res.statusCode == 500) {
							uni.showToast({
								title: "上传失败",
								icon: "error"
							})
							this.isSubmit = !this.isSubmit
							return
						}
						if (res.statusCode == 404) {
							uni.showToast({
								title: "上传失败",
								icon: "error"
							})
							this.isSubmit = !this.isSubmit
							return
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "上传失败",
							icon: "error"
						})
						this.isSubmit = !this.isSubmit
					}
				})
			},
			init() {
				setTimeout(() => {
					uni.showModal({
						title: "提示",
						content: "是否全部正常",
						cancelText: "否",
						confirmText: "是",
						success: (res) => {
							if (res.cancel) {
								// // a: {
								// // 	a1: "",
								// // 	a2: "正常",
								// // 	a3: "正常",
								// // 	a4: "正常",
								// // 	a5: "无隐患报告",
								// // },
								// this.a.a1 = ""
								// this.a.a2 = ""
								// this.a.a3 = ""
								// this.a.a4 = ""
								// this.a.a5 = ""
								// // b: {
								// // 	b1: "",
								// // 	b2: "正常",
								// // 	b3: "正常",
								// // 	b4: "正常",
								// // 	b5: "无隐患报告",
								// // },
								// this.b.b2 = ""
								// this.b.b3 = ""
								// this.b.b4 = ""
								// this.b.b5 = ""
								// // c: {
								// // 	c1: "正常",
								// // 	c2: "正常",
								// // 	c3: "正常",
								// // 	c4: "正常",
								// // 	c5: "正常",
								// // 	c6: "正常",
								// // 	c7: "正常",
								// // 	c8: "正常",
								// // 	c9: "无隐患报告",
								// // },
								// this.c.c1 = ""
								// this.c.c2 = ""
								// this.c.c3 = ""
								// this.c.c4 = ""
								// this.c.c5 = ""
								// this.c.c6 = ""
								// this.c.c7 = ""
								// this.c.c8 = ""
								// this.c.c9 = ""
								// // d: {
								// // 	d1: "",
								// // 	d2: "正常",
								// // 	d3: "正常",
								// // 	d4: "无隐患报告",
								// // 	d5: "",
								// // 	d6: "正常",
								// // 	d7: "正常",
								// // 	d8: "无隐患报告",
								// // },
								// this.d.d2 = ""
								// this.d.d3 = ""
								// this.d.d4 = ""
								// this.d.d6 = ""
								// this.d.d7 = ""
								// this.d.d8 = ""
								// // e: {
								// // 	e1: "正常",
								// // 	e2: "正常",
								// // 	e3: "无隐患报告"
								// // },
								// this.e.e1 = ""
								// this.e.e2 = ""
								// this.e.e3 = ""
								// // f: {
								// // 	f1: "",
								// // 	f2: "正常",
								// // 	f3: "无隐患报告"
								// // },
								// this.f.f2 = ""
								// this.f.f3 = ""
								// // j: {
								// // 	j1: "",
								// // 	j2: "正常",
								// // 	j3: "无隐患报告"
								// // },
								// this.j.j2 = ""
								// this.j.j3 = ""
								// // k: {
								// // 	k1: "正常",
								// // 	k2: "正常",
								// // 	k3: "无隐患报告"
								// // },
								// this.k.k1 = ""
								// this.k.k2 = ""
								// this.k.k3 = ""
								// // l: {
								// // 	l1: "正常",
								// // 	l2: "正常",
								// // 	l3: "无隐患报告"
								// // },
								// this.l.l1 = ""
								// this.l.l2 = ""
								// this.l.l3 = ""
								// // h: {
								// // 	h1: "正常",
								// // 	h2: "正常",
								// // 	h3: "正常",
								// // 	h4: "正常",
								// // 	h5: "无隐患报告",
								// // },
								// this.h.h1 = ""
								// this.h.h2 = ""
								// this.h.h3 = ""
								// this.h.h4 = ""
								// this.h.h5 = ""
								// // s: {
								// // 	s1: "",
								// // 	s2: "正常",
								// // 	s3: "正常",
								// // 	s4: "无隐患报告",
								// // },
								// this.s.s2 = ""
								// this.s.s3 = ""
								// this.s.s4 = ""
								// // q: {
								// // 	q1: "",
								// // 	q2: "正常",
								// // 	q3: "正常",
								// // 	q4: "正常",
								// // 	q5: "正常",
								// // 	q6: "无隐患报告",
								// // },
								// this.q.q2 = ""
								// this.q.q3 = ""
								// this.q.q4 = ""
								// this.q.q5 = ""
								// this.q.q6 = ""
								// // w: {
								// // 	w1: "正常",
								// // 	w2: "正常",
								// // 	w3: "正常",
								// // 	w4: "正常",
								// // 	w5: "无隐患报告",
								// // },
								// this.w.w1 = ""
								// this.w.w2 = ""
								// this.w.w3 = ""
								// this.w.w4 = ""
								// this.w.w5 = ""
								// // r: {
								// // 	r1: "",
								// // 	r2: "正常",
								// // 	r3: "无隐患报告",
								// // },
								// this.r.r2 = ""
								// this.r.r3 = ""
								// // t: {
								// // 	t1: "正常",
								// // 	t2: "正常",
								// // 	t3: "无隐患报告",
								// // },
								// this.t.t1 = ""
								// this.t.t2 = ""
								// this.t.t3 = ""
								// // y: {
								// // 	y1: "正常",
								// // 	y2: "正常",
								// // 	y3: "正常",
								// // 	y4: "无隐患报告",
								// // },
								// this.y.y1 = ""
								// this.y.y2 = ""
								// this.y.y3 = ""
								// this.y.y4 = ""
								// // u: {
								// // 	u1: "正常",
								// // 	u2: "正常",
								// // 	u3: "无隐患报告",
								// // },
								// this.u.u1 = ""
								// this.u.u2 = ""
								// this.u.u3 = ""
								// // i: {
								// // 	i1: "无",
								// // 	i2: ""
								// // },
								return
							}
							if (res.confirm) {
								uni.showLoading({
									title: "正在提交"
								})
								this.submit()
							}
						}
					})
				}, 1500)
			},
			getPrall() { //获取预设功能对象数据
			let pralldata = uni.getStorageSync("pralldata")
			this.preset = pralldata
				// let user = uni.getStorageSync("user")
				// let url = BASE_IP + "pc/presetfunction/find/presetFunction/" + user.unitId + "/" + user.uuid
				// uni.request({
				// 	header: {
				// 		"Authorization": user.token,
				// 	},
				// 	url: url,
				// 	success: (res) => {
				// 		this.preset = res.data
				// 	},
				// 	fail: (res) => {
				// 		// console.log("请求失败：", res)
				// 	}
				// })
			}
		},
		onLoad(ops) {
			uni.setNavigationBarTitle({
				title: "消防测试记录表"
			})
			this.getPrall()
			let user = uni.getStorageSync("user")
			// console.log(user)
			this.regime = JSON.parse(ops.regime)
			// console.log(this.regime)
			this.inspectionStaff.name = user.nickName

			const currentDate = moment();
			const year = currentDate.year();
			const month = currentDate.month() + 1;
			const day = currentDate.date();
			this.year = year
			this.month = month + "月"
			this.day = day
			this.inspectionStaff.data = year + "-" + month + "-" + day

			let pralldata = uni.getStorageSync("pralldata")



			this.inspectionStaff.time = pralldata.operatingTimeStart + " - " + pralldata.operatingTimeEnd

			const currentTime = moment().format("HH:mm");
			this.time = currentTime


			let recordTable = uni.getStorageSync("recordTable")

			this.i.i2 = recordTable.t17

			this.d.d1 = recordTable.t18

			this.d.d5 = recordTable.t19

			this.s.s1 = recordTable.t20

			this.q.q1 = recordTable.t21

			this.r.r1 = recordTable.t22

			this.init()




			// console.log("获取当前时间：", currentTime);
		}
	}
</script>

<style>
	page {
		background-color: #F1F4FA;
	}

	.tabs {
		width: 95%;
		margin: auto;
	}

	.tab {
		width: 100%;
		background-color: white;
		border-radius: 8px;
		/* margin: auto; */
		box-shadow: 1px 1px 10px #DCDFE6;
		padding-top: 10rpx;
		padding-bottom: 20rpx;
	}

	.fui-text__explain {
		font-size: 14px;
		color: #606266;
	}

	.tab_ops {
		padding: 40rpx;
		padding: 40rpx;
	}
</style>